package com.gionee.survey.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gionee.survey.bean.Answer;
import com.gionee.survey.dao.IAnswerDao;
import com.gionee.survey.service.IAnswerService;

/**
 * 
 * @author yuwei
 * @time 2017年4月12日 下午7:24:23
 */
@Service("answerService")
public class AnswerServiceImpl implements IAnswerService {
	@Resource
	private IAnswerDao answerDao;
	@Override
	public Answer selectByPrimaryKey(String id) {
		return answerDao.selectByPrimaryKey(id);
	}
	@Override
	public int deleteByPrimaryKey(String id) {
		return answerDao.deleteByPrimaryKey(id);
	}
	@Override
	public int insert(Answer record) {
		return answerDao.insert(record);
	}
	@Override
	public int insertSelective(Answer record) {
		return answerDao.insertSelective(record);
	}
	@Override
	public int updateByPrimaryKeySelective(Answer record) {
		return answerDao.updateByPrimaryKeySelective(record);
	}
	@Override
	public int updateByPrimaryKey(Answer record) {
		return answerDao.updateByPrimaryKey(record);
	}
	
	@Override
	public List<Answer> selectByQuestionId(String questionId) {
		return answerDao.selectByQuestionId(questionId);
	}
	
	/**
	 * 插入集合
	 * @param answers
	 * @return
	 */
	public int insert(List<Answer> answers){
		int i = 0;
		for (Answer answer : answers) {
			i += insert(answer);	// 调用本类方法
		}
		return i;
	}
	
	public IAnswerDao getAnswerDao() {
		return answerDao;
	}
	public void setAnswerDao(IAnswerDao answerDao) {
		this.answerDao = answerDao;
	}
}
